<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Base() {
            //window.this1 = this;
            console.log(this);
            this.name = 'js';
        }

        //new Base();
        let obj = {}
        obj.___proto = Base.prototype;
        Base.call(obj);
        //window.this2 = obj;
        console.log(obj.name);
        //
        Base();//里面的this 就是 window，默认是 window 调用的



        let str = new String('this is string');
        let bool = new Boolean();
        let obj2 = new Object();
        console.log(str);
        console.log(bool);
        console.log(obj2);

        //常见的一个面试的

        function user() {
            this.name = 'javescript';
            this.age = 19;
            this.login = function () {
                console.log('登录');
            }
        }

        //admin 如何去继承 user 里面的属性与方法，es5的继承，原型链
        function admin() {

        }
        // 指定了，admin的prototype
        admin.prototype = new user();

        let obj3 = new admin();
        console.log(obj3.name);
        console.log(obj3.age);
        console.log(obj3);

        function childAdmin() { }

        childAdmin.prototype = new admin();
        console.log(new childAdmin());

        //箭头函数

        let obj4 = {
            key1: 'js',
            key2: function () {
                console.log(this);// obj4
                console.log('study vue')
            },
            data: () => {
                console.log(this);// 箭头函数中没有this，出现this，就往上一层找
                console.log('study vue')
            },
            data2() {
                console.log('study vue')
            },
        }

        obj4.key2();
        obj4.data();

        //ES 出现了 class





        class Father {
            constructor() {
                this.study = 'js'
            }
        }

        class Son extends Father {

            constructor(name, age) {
                super();
                this.name = name;// 属性不需要在外层申明
                this.age = age;
            }
        }

        let obj5 = new Son('java', 30);
        console.log(obj5.study);







    </script>
</body>

</html>